package io.renren.modules.dangan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.utils.Constant;
import io.renren.modules.dangan.dao.DaDjgllDao;
import io.renren.modules.dangan.dao.DaWsDao;
import io.renren.modules.dangan.entity.DaDjgllEntity;
import io.renren.modules.dangan.entity.DaWsEntity;
import io.renren.modules.dangan.service.DaIndexService;
import io.renren.modules.sys.dao.SysDictDao;
import io.renren.modules.sys.entity.SysDictEntity;
import net.bytebuddy.agent.builder.AgentBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @auther guqianbin
 * @date 2019/9/15 16:23
 **/
@Service("daIndexService")
public class DaIndexServiceImpl implements DaIndexService {
    @Autowired
    private DaDjgllDao daDjgllDao;

    private static List<String> flhs=Arrays.asList("A综合","B财务","C地籍","D建设用地","E规划");


    @Autowired
    private DaWsDao daWsDao;

    @Autowired
    private SysDictDao sysDictDao;
    @Override
    public Map indexCountInf() {
        HashMap<String,Object> indexMap=new HashMap<>();
        List<String> flhDicts= Arrays.asList("A","B","C","D","E");
        List<String> szdList=Arrays.asList("市局","海曙","鄞州","高新区","江北","江东");
        indexMap.put("gcwz",szdList);
        indexMap.put("flhs",flhs);
        szdList.forEach(szd->{
            indexMap.put(szd,indexData(szd,flhDicts));
        });
        return indexMap;
    }

    private List<Integer> indexData(String szd,List<String> flhList){
        List<Integer> szdCount=new ArrayList<>();
        flhList.forEach(flh->{
            Integer fileCount=0;
            if(flh.equals("A")||flh.equals("B")){
                 fileCount= daWsDao.selectCount(new QueryWrapper<DaWsEntity>()
                        .eq("szd",szd)
                        .eq("pflh",flh));
            }else{
                 fileCount=daDjgllDao.selectCount(new QueryWrapper<DaDjgllEntity>()
                            .eq("szd",szd)
                            .eq("pflh",flh));
            }
            szdCount.add(fileCount);
        });

        return szdCount;
    }



}
